#include "CHelp.h"

#include "Enum.h"

#include "Utility.h"
#include "Animation.h"
#include "SpriteMaker.h"
#include <OIS/OISKeyboard.h>

int const RIGHT_BUTTON_X = 806;
int const LEFT_BUTTON_X = 50;
int const BUTTON_Y = -640;

int const BUTTON_HALF_WIDTH = 95;
int const BUTTON_HALF_HEIGHT = -45;

int const MAX_PAGE_NUMBER = 8;

int const BACKGROUND_X = 512;
int const BACKGROUND_Y = -384;


CHelp::CHelp(void)
{
	m_nNowPageNumber = 1;
}

CHelp::~CHelp(void)
{
	SharedSpriteMaker.getSprite(eBackgroundTag_Help_1)->setPosition(-10000, 10000, eBackgroundTag_Help_1);
	SharedSpriteMaker.getSprite(eBackgroundTag_Help_2)->setPosition(-10000, 10000, eBackgroundTag_Help_2);
	SharedSpriteMaker.getSprite(eBackgroundTag_Help_3)->setPosition(-10000, 10000, eBackgroundTag_Help_3);
	SharedSpriteMaker.getSprite(eBackgroundTag_Help_4)->setPosition(-10000, 10000, eBackgroundTag_Help_4);
	SharedSpriteMaker.getSprite(eBackgroundTag_Help_5)->setPosition(-10000, 10000, eBackgroundTag_Help_5);
	SharedSpriteMaker.getSprite(eBackgroundTag_Help_6)->setPosition(-10000, 10000, eBackgroundTag_Help_6);
	SharedSpriteMaker.getSprite(eBackgroundTag_Help_7)->setPosition(-10000, 10000, eBackgroundTag_Help_7);
	SharedSpriteMaker.getSprite(eBackgroundTag_Help_8)->setPosition(-10000, 10000, eBackgroundTag_Help_8);
}

void CHelp::put(void)
{
	switch(m_nNowPageNumber)
	{
	case 1 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_1)->setPosition(BACKGROUND_X, BACKGROUND_Y, eBackgroundTag_Help_1);
		}
		break;

	case 2 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_2)->setPosition(BACKGROUND_X, BACKGROUND_Y, eBackgroundTag_Help_2);
		}
		break;

	case 3 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_3)->setPosition(BACKGROUND_X, BACKGROUND_Y, eBackgroundTag_Help_3);
		}
		break;

	case 4 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_4)->setPosition(BACKGROUND_X, BACKGROUND_Y, eBackgroundTag_Help_4);
		}
		break;

	case 5 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_5)->setPosition(BACKGROUND_X, BACKGROUND_Y, eBackgroundTag_Help_5);
		}
		break;

	case 6 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_6)->setPosition(BACKGROUND_X, BACKGROUND_Y, eBackgroundTag_Help_6);
		}
		break;

	case 7 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_7)->setPosition(BACKGROUND_X, BACKGROUND_Y, eBackgroundTag_Help_7);
		}
		break;

	case 8 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_8)->setPosition(BACKGROUND_X, BACKGROUND_Y, eBackgroundTag_Help_8);
		}
		break;

	default :
		{
		}
	}
}

void CHelp::setKeyBoardState(int const _nState,int const _nKey)
{
}

void CHelp::setMouseState(const int _nState, const int _nX, const int _nY)
{
	m_nMouseState = _nState;
	m_nMouseX = _nX;
	m_nMouseY = _nY;
	if(eMouseRightButton_Release == m_nMouseState)
	{
		m_nSceneState = false;
	}
	else if(eMouseLeftButton_Release == m_nMouseState)
	{
		mouseButtonHitCheck();
	}
}

int CHelp::run(void)
{
	if(false == m_nSceneState)
	{
		return eScene_Main;
	}
	else
	{
		return eScene_Help;
	}
}

void CHelp::mouseButtonHitCheck(void)
{
	if(BUTTON_Y >= m_nMouseY && BUTTON_Y + BUTTON_HALF_HEIGHT * 2 <= m_nMouseY)
	{
		if(LEFT_BUTTON_X <= m_nMouseX && LEFT_BUTTON_X + BUTTON_HALF_WIDTH * 2 >= m_nMouseX)
		{
			pageMove(eLeft);
		}
		else if(RIGHT_BUTTON_X <= m_nMouseX && RIGHT_BUTTON_X + BUTTON_HALF_WIDTH * 2>= m_nMouseX)
		{
			pageMove(eRight);
		}
	}
	m_nMouseState = eMouse_Stop;
}

void CHelp::pageMove(int _nArrow)
{
	switch(_nArrow)
	{
	case eLeft :
		{
			ImgRemove();
			if(1 >= m_nNowPageNumber)
			{
				m_nNowPageNumber = MAX_PAGE_NUMBER;
			}
			else
			{
				--m_nNowPageNumber;
			}
		}
		break;

	case eRight :
		{
			ImgRemove();
			if(MAX_PAGE_NUMBER <= m_nNowPageNumber)
			{
				m_nNowPageNumber = 1;
			}
			else
			{
				++m_nNowPageNumber;
			}
		}
		break;

	default :
		{
		}
	}
}

void CHelp::ImgRemove(void)
{
	switch(m_nNowPageNumber)
	{
	case 1 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_1)->setPosition(-10000, 10000, eBackgroundTag_Help_1);
		}
		break;

	case 2 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_2)->setPosition(-10000, 10000, eBackgroundTag_Help_2);
		}
		break;

	case 3 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_3)->setPosition(-10000, 10000, eBackgroundTag_Help_3);
		}
		break;

	case 4 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_4)->setPosition(-10000, 10000, eBackgroundTag_Help_4);
		}
		break;

	case 5 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_5)->setPosition(-10000, 10000, eBackgroundTag_Help_5);
		}
		break;

	case 6 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_6)->setPosition(-10000, 10000, eBackgroundTag_Help_6);
		}
		break;

	case 7 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_7)->setPosition(-10000, 10000, eBackgroundTag_Help_7);
		}
		break;

	case 8 :
		{
			SharedSpriteMaker.getSprite(eBackgroundTag_Help_8)->setPosition(-10000, 10000, eBackgroundTag_Help_8);
		}
		break;

	default :
		{
		}
	}
}